package com.pagoda.nerp.trade.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pagoda.nerp.trade.common.PageListResult;
import com.pagoda.nerp.trade.dao.MdRoleDao;
import com.pagoda.nerp.trade.entity.MdRole;
import com.pagoda.nerp.trade.service.MdRoleService;

@Service
public class MdRoleServiceImpl implements MdRoleService{

	@Autowired
	public MdRoleDao mdRoleDao;
	
    @Override
    public Object listMdRole(Map con) throws Exception {
        int pageNo = con.get("pageNo") != null ? Integer.parseInt(con.get("pageNo").toString()) : 1;
        int pageSize = con.get("pageSize") != null ?  Integer.parseInt(con.get("pageSize").toString()) : 0;
        Page pageInfo = PageHelper.startPage(pageNo, pageSize);
        List<MdRole> listRole = (List<MdRole>) mdRoleDao.selectAllByConditon(con);
        return new PageListResult<MdRole>( pageInfo,listRole);
    }

    @Override
    public Object findMdRole(Map map) throws Exception {
        return mdRoleDao.selectOneByCondition(map);
    }

	public List<MdRole> selectByCondition(Integer accountId) {
		return mdRoleDao.selectByCondition(accountId);
	}
	
}
